package com.src.notebookofcy;

import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import cn.domob.android.ads.DomobAdView;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@SuppressLint({"UseSparseArrays"})
public class Main
{
  private DomobAdView adView;
  int dialogIndex = 0;
  public DialogInterface.OnClickListener dialogOnClickListener = new DialogInterface.OnClickListener()
  {
    public void onClick(DialogInterface paramDialogInterface, int paramInt)
    {
      switch (paramInt)
      {
      default:
        return;
      case -1:
        if (Main.this.dialogIndex == 0)
        {
          Intent localIntent = new Intent();
          localIntent.putExtra("STATE", 1);
          localIntent.setClass(Main.this.mainActivity, EditActivity.class);
          Main.this.mainActivity.startActivity(localIntent);
          return;
        }
        FileTools.deleteFile(Main.this.itemFile);
        Main.this.addData();
        Main.this.myBaseAdapter.notifyDataSetChanged();
        return;
      case -2:
        Main.this.dismissDialog(1);
        return;
      case 0:
        Main.this.dialogIndex = 0;
        return;
      case 1:
      }
      Main.this.dialogIndex = 1;
    }
  };
  private File itemFile;
  private LayoutInflater layoutInflater;
  private List<ListModle> listData;
  private ListView listView;
  private MainActivity mainActivity;
  private Map<Integer, AlertDialog> map;
  private MyBaseAdapter myBaseAdapter;
  public AdapterView.OnItemClickListener onItemClickListener = new AdapterView.OnItemClickListener()
  {
    public void onItemClick(AdapterView<?> paramAdapterView, View paramView, int paramInt, long paramLong)
    {
      Main.ListModle localListModle = (Main.ListModle)Main.this.listData.get(paramInt);
      Main.this.itemFile = localListModle.getFile();
      SimpleClass.getSimpleClass();
      SimpleClass.setFile(Main.this.itemFile);
      Main.this.openFile(paramInt);
    }
  };
  public AdapterView.OnItemLongClickListener onItemLongClickListener = new AdapterView.OnItemLongClickListener()
  {
    public boolean onItemLongClick(AdapterView<?> paramAdapterView, View paramView, int paramInt, long paramLong)
    {
      Main.this.itemFile = ((Main.ListModle)Main.this.listData.get(paramInt)).getFile();
      SimpleClass.getSimpleClass();
      SimpleClass.setFile(Main.this.itemFile);
      Main.this.showDialog(1);
      return true;
    }
  };
  private RelativeLayout relativeLayout;

  public Main(MainActivity paramMainActivity)
  {
    this.mainActivity = paramMainActivity;
    this.layoutInflater = LayoutInflater.from(paramMainActivity);
    dataInit();
    viewInit();
    transmitData();
    AdInit();
  }

  public void AdInit()
  {
    this.relativeLayout = ((RelativeLayout)this.mainActivity.findViewById(2131165185));
    this.relativeLayout.setVisibility(8);
    this.adView = new DomobAdView(this.mainActivity, "56OJztiouNf4jxykjR", "320x50");
    this.relativeLayout.addView(this.adView);
  }

  public void addData()
  {
    this.listData.clear();
    List localList = FileTools.getTextFile(FileTools.documents);
    File[] arrayOfFile1 = new File[localList.size()];
    int i = 0;
    File[] arrayOfFile2;
    int j;
    if (i >= arrayOfFile1.length)
    {
      arrayOfFile2 = FileTools.sortFileByTime(arrayOfFile1);
      if (FileTools.documents.exists())
        j = arrayOfFile2.length;
    }
    for (int k = 0; ; ++k)
    {
      if (k >= j)
      {
        return;
        arrayOfFile1[i] = ((File)localList.get(i));
        ++i;
      }
      File localFile = arrayOfFile2[k];
      ListModle localListModle = new ListModle();
      localListModle.setFile(localFile);
      this.listData.add(localListModle);
    }
  }

  public AlertDialog createDialog(int paramInt)
  {
    AlertDialog.Builder localBuilder = new AlertDialog.Builder(this.mainActivity);
    switch (paramInt)
    {
    default:
      return localBuilder.create();
    case 1:
      return operate(localBuilder).create();
    case 2:
    }
    return localBuilder.setTitle("关于").setMessage("欢迎使用流年记事本，本应用旨在简洁易用。记录流年。时光便签。流年。").setPositiveButton("确定", new DialogInterface.OnClickListener()
    {
      public void onClick(DialogInterface paramDialogInterface, int paramInt)
      {
      }
    }).create();
  }

  public void dataInit()
  {
    this.listData = new ArrayList();
    this.map = new HashMap();
    addData();
  }

  public void dismissDialog(int paramInt)
  {
    if (!this.map.containsKey(Integer.valueOf(paramInt)))
      return;
    ((AlertDialog)this.map.get(Integer.valueOf(paramInt))).dismiss();
  }

  public void editText()
  {
  }

  public void newText()
  {
    ((Button)this.mainActivity.findViewById(2131165187)).setOnClickListener(new View.OnClickListener()
    {
      public void onClick(View paramView)
      {
        Main.this.relativeLayout.setVisibility(0);
        Intent localIntent = new Intent();
        localIntent.putExtra("STATE", 0);
        localIntent.setClass(Main.this.mainActivity, EditActivity.class);
        Main.this.mainActivity.startActivity(localIntent);
      }
    });
  }

  public void openFile(int paramInt)
  {
    Intent localIntent = new Intent("android.intent.action.VIEW");
    localIntent.setClass(this.mainActivity, TextViewActivity.class);
    this.mainActivity.startActivity(localIntent);
  }

  public AlertDialog.Builder operate(AlertDialog.Builder paramBuilder)
  {
    String[] arrayOfString = { "编辑", "删除" };
    paramBuilder.setTitle("操作").setPositiveButton("确定", this.dialogOnClickListener).setNegativeButton("取消", this.dialogOnClickListener).setSingleChoiceItems(arrayOfString, 0, this.dialogOnClickListener);
    return paramBuilder;
  }

  public void showDialog(int paramInt)
  {
    if (this.map.containsKey(Integer.valueOf(paramInt)))
    {
      ((AlertDialog)this.map.get(Integer.valueOf(paramInt))).show();
      return;
    }
    AlertDialog localAlertDialog = createDialog(paramInt);
    this.map.put(Integer.valueOf(paramInt), localAlertDialog);
    localAlertDialog.show();
  }

  public void transmitData()
  {
    SimpleClass.getSimpleClass().setMyBaseAdapter(this.myBaseAdapter);
  }

  public void viewInit()
  {
    this.listView = ((ListView)this.mainActivity.findViewById(2131165184));
    this.myBaseAdapter = new MyBaseAdapter();
    this.listView.setAdapter(this.myBaseAdapter);
    this.listView.setOnItemClickListener(this.onItemClickListener);
    this.listView.setOnItemLongClickListener(this.onItemLongClickListener);
    newText();
  }

  public class GetViewOptimize
  {
    TextView tv_time;
    TextView tv_title;

    public GetViewOptimize()
    {
    }
  }

  public class ListModle
  {
    File file;

    public ListModle()
    {
    }

    public File getFile()
    {
      return this.file;
    }

    public void setFile(File paramFile)
    {
      this.file = paramFile;
    }
  }

  public class MyBaseAdapter extends BaseAdapter
  {
    public MyBaseAdapter()
    {
    }

    public int getCount()
    {
      return Main.this.listData.size();
    }

    public Object getItem(int paramInt)
    {
      return Main.this.listData.get(paramInt);
    }

    public long getItemId(int paramInt)
    {
      return paramInt;
    }

    public View getView(int paramInt, View paramView, ViewGroup paramViewGroup)
    {
      File localFile = ((Main.ListModle)Main.this.listData.get(paramInt)).getFile();
      Main.GetViewOptimize localGetViewOptimize;
      if (paramView == null)
      {
        paramView = Main.this.layoutInflater.inflate(2130903044, null);
        localGetViewOptimize = new Main.GetViewOptimize(Main.this);
        localGetViewOptimize.tv_title = ((TextView)paramView.findViewById(2131165198));
        localGetViewOptimize.tv_time = ((TextView)paramView.findViewById(2131165199));
        paramView.setTag(localGetViewOptimize);
      }
      while (true)
      {
        localGetViewOptimize.tv_title.setText(localFile.getName().substring(0, -4 + localFile.getName().length()));
        localGetViewOptimize.tv_time.setText(FileTools.getTimeFormat(localFile));
        return paramView;
        localGetViewOptimize = (Main.GetViewOptimize)paramView.getTag();
      }
    }
  }
}

/* Location:           C:\Users\god\Desktop\liunianjishiben_V1.1_mumayi_3745b_dex2jar.jar
 * Qualified Name:     com.src.notebookofcy.Main
 * JD-Core Version:    0.5.4
 */